'use strict';

var MVTbeavip = (function($){

  var _layout_mode, $ww, $mw, $ww_message, $mm_message;

  var addLinks = function(){



    $ww.parent()
      .after('<li class="spacer"></li><li>'+
              '<a href="http://www.asos.com/Features/asseenonme/Cat/pgehtml.aspx?cid=18983&WT.ac=WW|Nav|OlapicGallery">'+
                '<b>'+$ww_message+'</b>'+
              '</a>'+
            '</li>');

    if(_layout_mode == 'legacy'){

      $mw.parent()
        .after('<li class="spacer"></li>'+
               '<li>'+
                  '<a href="http://www.asos.com/Features/asseenonme/Cat/pgehtml.aspx?cid=19018&WT.ac=MW|Nav|OlapicGallery">'+
                    '<b>'+$ww_message+'</b>'+
                  '</a>'+
                '</li>');

    }else{

      $mw.parent()
        .after('<li class="spacer"></li>'+
               '<li>'+
                  '<a href="http://www.asos.com/Features/asseenonme/Cat/pgehtml.aspx?cid=19018&WT.ac=MW|Nav|OlapicGallery">'+
                    '<b>'+$ww_message+'</b>'+
                  '</a>'+
                '</li>');

    }


  };

  var init = function(layout_mode){

    _layout_mode = layout_mode;

    if(layout_mode == 'new'){

      $ww_message = '#AsSeenOnMe Gallery';
      $mm_message = '#AsSeenOnMe Gallery';

      $ww = $('li.floor_1 ul.items li a:contains("A To Z Of Brands")');
      $mw = $('li.floor_2 ul.items li a:contains("Premium Brands")');

    }else if(layout_mode == 'legacy'){

       $ww_message = '#AsSeenOnMe Gallery';
      $mm_message = '#AsSeenOnMe Gallery';

      $ww = $('li#floor_1 ul.items li a:contains("A To Z Of Brands")');
      $mw = $('li#floor_2 ul.items li a:contains("Premium Brands")');

    }else{
      return;
    }

    addLinks();

  };

  return {
    init:init
  };

})(window.jQuery);

window.jQuery(document).ready(function($) {

  var layout_mode = $('.frame').length ? 'new' : 'legacy';

  MVTbeavip.init(layout_mode);

});
